package flc.ast.fragment;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;

import java.util.ArrayList;
import java.util.List;

import flc.ast.activity.DrawActivity;
import flc.ast.R;
import flc.ast.adapter.DrawAdapter;
import flc.ast.bean.MyDrawBean;
import flc.ast.databinding.FragmentHomeBinding;
import stark.common.basic.base.BaseNoModelFragment;
import stark.common.basic.event.EventStatProxy;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link HomeFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class HomeFragment extends BaseNoModelFragment<FragmentHomeBinding> {

    private DrawAdapter drawAdapter;


    @Override
    protected int onCreate() {
        return R.layout.fragment_home;
    }

    @Override
    protected void initView() {
        EventStatProxy.getInstance().statEvent1(getActivity(), mDataBinding.event1Container);
        EventStatProxy.getInstance().statEvent5(getActivity(), mDataBinding.event5Container);
        mDataBinding.rvDrawList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL,false));
        drawAdapter = new DrawAdapter();
        mDataBinding.rvDrawList.setAdapter(drawAdapter);
        drawAdapter.setOnItemClickListener(this);
    }

    @Override
    protected void onItemClickCallback(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
        DrawActivity.imgBg = drawAdapter.getItem(position).getImgShow();
        startActivity(DrawActivity.class);
    }

    @Override
    protected void initData() {
        List<MyDrawBean> listDraw = new ArrayList<>();
        listDraw.add(new MyDrawBean(R.drawable.x1, R.drawable.d1,R.drawable.kk1));
        listDraw.add(new MyDrawBean(R.drawable.x2, R.drawable.d2,R.drawable.kk2));
        listDraw.add(new MyDrawBean(R.drawable.x3, R.drawable.d3,R.drawable.kk3));
        listDraw.add(new MyDrawBean(R.drawable.x4, R.drawable.d4,R.drawable.kk1));
        listDraw.add(new MyDrawBean(R.drawable.x5, R.drawable.d5,R.drawable.kk2));
        listDraw.add(new MyDrawBean(R.drawable.x6, R.drawable.d6,R.drawable.kk3));
        listDraw.add(new MyDrawBean(R.drawable.x7, R.drawable.d7,R.drawable.kk1));
        listDraw.add(new MyDrawBean(R.drawable.x8, R.drawable.d8,R.drawable.kk2));
        drawAdapter.setList(listDraw);
    }
}